home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS14.ADF
/
AmigaBasicProgs
/
BMAPReader
/
BmapReader
< prev
next >
Wrap
Text File
|
1989-01-28
|
10KB
|
339 lines
Initialize:
FALSE = 0 : TRUE = -1 ' Just because!
BobRight = 230 : BobBottom = 90 ' The sides of our requestor
DEF FNArraySize& = 3 + INT((BobRight + 16)/16)*(BobBottom+1)*2
DECLARE FUNCTION Move LIBRARY
DECLARE FUNCTION SetDrMd LIBRARY
LIBRARY "graphics.library"
Title$ = " .bmap Reader Tim Jones "
Title$ = Title$ + CHR$(169) + " 1986 AmSoft Developement"
WINDOW 1,Title$,(0,0)-(631,186),0
PALETTE 0,0,0,0
PALETTE 3,.8,.2,.1
PALETTE 1,.1,.7,.1
PALETTE 2,.9,.9,.1
Rp& = WINDOW(8)
Start:
COLOR 1,0 : CLOSE 1
GOSUB NameRequestor
IF NOT Okay THEN
CLS : LIBRARY CLOSE
WINDOW 1,"BmapReader",(0,0)-(617,186),15,-1 : STOP
END IF
ON ERROR GOTO FileProb ' this screws things up if you use other than the
' default workbench screen
IF UCASE$(RIGHT$(FileName$,5)) <> ".BMAP" THEN
FileName$ = FileName$ + ".bmap"
END IF
OPEN FileName$ FOR INPUT AS 1
Prompt$ = "" : Prompt2$ = " Output to Printer?"
GOSUB YNRequestor : IF Okay THEN fPrt = TRUE : GOTO Printer
CLS
LINE(3,13)-(628,170),1,b
LINE(4,13)-(627,170),1,b
Length& = LOF(1)
LOCATE 23,1 : PRINT Length&;"Bytes read. FILE: ";: COLOR 2,0 : PRINT FileName$;
CALL Move&(Rp&,10,10) : COLOR 3,0
PRINT "Routine Name Address d0 d1 d2 d3 d4 d5 d6 d7 a0 a1 a2 a3 a4"
COLOR 1,0
GetTheFile:
WHILE NOT EOF(1)
FOR L = 3 TO 21
IF EOF(1) THEN
FOR J = L TO 21
LOCATE J,2
PRINT SPACE$(75)
NEXT J
GOTO Finished
END IF
GOSUB GetRoutName
COLOR 1,0
LOCATE L,2
PRINT " ";Routine$
GOSUB GetEntryAdd
LOCATE L,25
IF LEN(Address$(2)) = 1 THEN
Address$(2) = "0" + Address$(2)
END IF
PRINT Address$(1);Address$(2)
GOSUB GetRegInfo
LOCATE L,35
PRINT
NEXT L
COLOR 0,3
LINE(386,173)-(612,185),3,bf
LINE(388,174)-(610,184),0,b
CALL Move&(Rp&,394,182) : PRINT "F1 continues <> F10 aborts";
WaitKey:
In$ = INKEY$ : IF In$ = "" THEN WaitKey
IF In$ = CHR$(138) THEN
LINE(386,173)-(612,185),0,bf
GOTO Finished
END IF
IF In$ <> CHR$(129) THEN WaitKey
COLOR 1,0
LINE(386,173)-(612,185),0,bf
WEND
GOTO Finished
GetRoutName:
Routine$ = ""
GOSUB GetChar
WHILE Char$ <> CHR$(0)
Routine$ = Routine$ + Char$
GOSUB GetChar
WEND
IF LEN(Routine$) < 30 THEN
Routine$ = Routine$ + SPACE$(20 - LEN(Routine$))
END IF
RETURN
GetEntryAdd:
FOR ii = 1 TO 2
GOSUB GetChar
Address$(ii) = HEX$(ASC(Char$))
NEXT ii
RETURN
GetRegInfo:
LOCATE L,35 : PRINT SPACE$(42);
WHILE Char$ <> CHR$(0)
GOSUB GetChar
COLOR 2,0
Register = ASC(Char$)
GOSUB R1
WEND
IF fPrt THEN PRINT #4," "
RETURN
GetChar:
IF NOT EOF(1) THEN Char$ = INPUT$(1,1)
RETURN
Finished:
COLOR 3,0
LOCATE 23,1
PRINT SPACE$(78);
LOCATE 23,1
PRINT " Do you wish to examine another .BMAP file (Y/N)?";
test:
In$ = INKEY$ : IF In$ = "" THEN test
IF UCASE$(In$) <> "Y" THEN
CLS : CLOSE 1 : LIBRARY CLOSE : WINDOW CLOSE 1
WINDOW 1,"BmapReader",(0,0)-(617,186),15,-1 : STOP
END IF
GOTO Start
R1:
IF Register < 1 THEN RETURN
IF Register > 8 THEN R2
IF fPrt THEN
PRINT #4,CHR$(141);TAB(32 + (Register * 3));"#";
RETURN
END IF
LOCATE L,(32 + (Register * 3))
PRINT "#"
RETURN
R2:
IF fPrt THEN
PRINT #4,CHR$(141);TAB(34 + (Register * 3));"#";
RETURN
END IF
LOCATE L,(34 + (Register *3))
PRINT "#"
RETURN
Printer:
OPEN "LPT1:BIN" FOR OUTPUT AS 4
PRINT #4,CHR$(14);"Contents of file ";FileName$
PRINT #4," "
WHILE NOT EOF(1)
PRINT #4,"Routine Name Address d0 d1 d2 d3 d4 d5 d6 d7 a0 a1 a2 a3 a4"
PRINT #4,"------------ ------- -- -- -- -- -- -- -- -- -- -- -- -- --"
FOR L = 1 TO 54
IF EOF(1) THEN
GOTO Finished
END IF
GOSUB GetRoutName
PRINT #4," ";Routine$;
GOSUB GetEntryAdd
IF LEN(Address$(2)) = 1 THEN
Address$(2) = "0" + Address$(2)
END IF
PRINT #4," ";Address$(1);Address$(2);
GOSUB GetRegInfo
NEXT L
PRINT #4,CHR$(12)
WEND
PRINT #4,CHR$(12)
CLOSE 4 : fPrt = FALSE
GOTO Start
FileProb:
flag = ERR
Prompt$ = ""
Prompt2$ = " Error! >>"+ STR$(ERR)
GOSUB YNRequestor
IF NOT Okay THEN
LIBRARY CLOSE
CLOSE 1
WINDOW CLOSE 1
WINDOW 1,"BmapReader",(0,0)-(617,186),31,-1
END
END IF
RESUME Start
NameRequestor:
Size& = FNArraySize&\2
DIM ScrSav&(Size&)
GET(40,40)-(230,90),ScrSav&
DrawRequestorToScreen2:
LINE(40,40)-(230,90),1,bf 'Main requestor box
LINE(40,40)-(230,90),0,b 'outline for main requestor box
LINE(44,42)-(226,88),0,b 'secondary outline for main box
LINE(50,74)-(72,86),3,bf 'OK button box
LINE(50,74)-(72,86),0,b 'OK outline
LINE(150,74)-(220,86),3,bf 'CANCEL button box
LINE(150,74)-(220,86),0,b 'CANCEL outline
CALL Move&(Rp&,53,83) 'Position for printing OK in button
COLOR 0,3 : PRINT "OK" 'print it
CALL Move&(Rp&,160,83) 'Position for printing CANCEL button
COLOR 0,3 : PRINT "CANCEL" 'print it
LINE(53,50)-(216,62),3,b
Curs = 55 : LINE(Curs,52)-(Curs+7,60),2,bf ' Print the pseudo-cursor
CALL Move&(Rp&,53,71) : COLOR 0,1 : PRINT " Enter File Name"
C$ = INKEY$ : WHILE C$ <> "" : C$ = INKEY$ : WEND 'Empty keyboard buffer
FileName$ = ""
AccessLoop: ' Wait for click in string box or CANCEL
I = MOUSE(0) : X = MOUSE(1) : Y = MOUSE(2)
IF I <> 0 THEN
WHILE I <> 0 : I = MOUSE(0) : X = MOUSE(1) : Y = MOUSE(2) : WEND
Y=Y-1 ' This is due to a difference in MOUSE(2) and the actual Window
' location
IF X > 150 AND X < 220 AND Y > 74 AND Y < 86 THEN ' Check for CANCEL
CALL SetDrMd&(Rp&,2) : LINE(151,75)-(219,85),0,bf
CALL SetDrMd&(Rp&,1)
Okay = FALSE : FOR Delay = 1 TO 1000 : NEXT Delay
PUT(40,40),ScrSav&,PSET
ERASE ScrSav& : COLOR 1,0 : RETURN
END IF
IF X > 53 AND X < 216 AND Y > 50 AND Y < 62 THEN
LINE(Curs,52)-(Curs+7,60),0,bf
FOR Delay = 1 TO 50 : NEXT Delay
LINE(Curs,52)-(Curs+7,60),2,bf
WHILE INKEY$ <> "" : WEND
GOTO Loop
END IF
END IF
GOTO AccessLoop
Loop: ' We do this until CANCEL, OK or Carriage Return
C$ = INKEY$ : I = MOUSE(0) : X = MOUSE(1) : Y = MOUSE(2)
IF I <> 0 THEN
WHILE I <> 0 : I = MOUSE(0) : X = MOUSE(1) : Y = MOUSE(2) : WEND
Y=Y-1 ' This is due to a difference in MOUSE(2) and the actual Window
' location
IF X > 150 AND X < 220 AND Y > 74 AND Y < 86 THEN ' Check for CANCEL
CALL SetDrMd&(Rp&,2) : LINE(151,75)-(219,85),0,bf
CALL SetDrMd&(Rp&,1)
Okay = FALSE : FOR Delay = 1 TO 1000 : NEXT Delay
PUT(40,40),ScrSav&,PSET
ERASE ScrSav& : COLOR 1,0 : RETURN
END IF
IF X > 50 AND X < 72 AND Y > 74 AND Y < 86 AND LEN(FileName$) > 0 THEN
' Check for OK and length of file
CALL SetDrMd&(Rp&,2) : LINE(51,75)-(71,85),0,bf
CALL SetDrMd&(Rp&,1)
FOR Delay = 1 TO 1000 : NEXT Delay : Okay = TRUE : fExist = TRUE
PUT(40,40),ScrSav&,PSET
ERASE ScrSav& : COLOR 1,0 : RETURN
END IF
END IF
IF C$ = "" THEN GOTO Loop
IF LEN(FileName$) = 0 THEN IF C$ < "A" AND ASC(C$) <> 13 GOTO Loop
' Don't allow non-Alpha characters as first character
IF ASC(C$) = 13 THEN
Okay = TRUE : fExist = TRUE
PUT(40,40),ScrSav&,PSET
ERASE ScrSav& : COLOR 1,0 : RETURN
END IF
IF ASC(C$) = 8 THEN
' Capture the BackSpace and fix display and filename
FileName$ = LEFT$(FileName$,LEN(FileName$)-1)
LINE(Curs,52)-(Curs+7,60),1,bf
Curs = Curs-8 : LINE(Curs,52)-(Curs+7,60),2,bf
GOTO Loop
END IF
IF LEN(FileName$) = 19 THEN GOTO Loop
IF ASC(C$) = 8 THEN Loop
IF C$ < " " OR (C$ > "Z" AND C$ < "a") OR C$ > "z" GOTO Loop
FileName$ = FileName$ + C$
LINE(Curs,52)-(Curs+7,60),1,bf
COLOR 0,1 : CALL Move&(Rp&,0,59) : PRINT PTAB(Curs);C$;
Curs = Curs + 8 : LINE(Curs,52)-(Curs+7,60),2,bf
GOTO Loop
YNRequestor:
Size& = FNArraySize&\2 'to reserve memory for the GET statement
DIM ScrSav&(Size&) 'this is the actual array to hold the bitmap
GET(40,40)-(230,90),ScrSav& 'defines a rectangle and remembers it as
LINE(40,40)-(230,90),2,bf 'Main requestor box
LINE(40,40)-(230,90),0,b 'outline for main requestor box
LINE(44,42)-(226,88),0,b 'secondary outline for main box
LINE(50,74)-(72,86),3,bf 'OK button box
LINE(50,74)-(72,86),0,b 'OK outline
LINE(150,74)-(220,86),3,bf 'CANCEL button box
LINE(150,74)-(220,86),0,b 'CANCEL outline
CALL Move&(Rp&,53,83) 'Position for printing OK in button
COLOR 0,3 : PRINT "OK" 'print it
CALL Move&(Rp&,160,83) 'Position for printing CANCEL button
COLOR 0,3 : PRINT "CANCEL" 'print it
CALL Move&(Rp&,54,52) 'Position for printing first line of text
COLOR 0,2 : PRINT Prompt$ 'print it
CALL Move&(Rp&,54,62) 'Position for printing second line of text
COLOR 3,2 : PRINT Prompt2$ 'print it
GetButton2:
' This waits for a mouse click (left mouse button)
I = MOUSE(0) : X = MOUSE(1) : Y = MOUSE(2)
IF I <> 0 THEN
WHILE I<>0 : I = MOUSE(0) : X = MOUSE(1) : Y = MOUSE(2) : Y = Y-1
WEND
Cancel: ' Check to see if the CANCEL button is selected
IF X > 150 AND X < 220 AND Y > 74 AND Y < 86 THEN
CALL SetDrMd&(Rp&,2) ' COMPLIMENT the CANCEL button
LINE(151,75)-(219,85),0,bf
CALL SetDrMd&(Rp&,1)
FOR Delay = 1 TO 1000 : NEXT Delay ' Let the user SEE his/her choice
PUT(40,40),ScrSav&,PSET ' Replace the old screen display
ERASE ScrSav& ' Erase the Array
Okay = FALSE ' Indicates that CANCEL was selected
COLOR 1,0
RETURN
END IF
Ok: ' Check to see if the OK button is selected
IF X > 50 AND X < 72 AND Y > 74 AND Y < 86 THEN
CALL SetDrMd&(Rp&,2) ' COMPLIMENT the OK button
LINE(51,75)-(71,85),0,bf
CALL SetDrMd&(Rp&,1)
FOR Delay = 1 TO 1000 : NEXT Delay ' Let the user SEE his/her choice
PUT(40,40),ScrSav&,PSET ' Replace the old screen display
Okay = TRUE ' Erase the Array
ERASE ScrSav& ' Indicates that OK was selected
COLOR 1,0
RETURN
END IF
END IF
GOTO GetButton2 ' Until a button is selected